package com.education.wisdom.controller.order;


import com.education.wisdom.pojo.OrderAnswer;
import com.education.wisdom.service.OrderAnswerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Date;

import static com.education.common.core.BaseController.writeJSON;


/**
 * 答案表
 *
 * @date 2021-03-04 15:45:19
 */
@RestController
@RequestMapping("/wisdom/orderanswer")
public class OrderAnswerController {

    @Autowired
    private OrderAnswerService orderAnswerService;


    //添加答卷
    @PostMapping("/addanswer")
    public void addanswer(HttpServletResponse response, OrderAnswer orderAnswer) throws IOException {
        orderAnswer.setCreateTime(new Date());
        writeJSON(orderAnswerService.insertOrderAnswer(orderAnswer),response, "200", "添加成功");

    }

    //删除答卷
    @PostMapping("/deleteanswer")
    public void deleteanswer(HttpServletResponse response, OrderAnswer orderAnswer, String[] ids) throws IOException{
        writeJSON(orderAnswerService.deleteOrderAnswerByIds(ids),response,"200","删除成功");
    }

    //修改答卷
    @PostMapping("/updateanswer")
    public void updateanswer(HttpServletResponse response, OrderAnswer orderAnswer) throws IOException{
        orderAnswer.setUpdateTime(new Date());
        writeJSON(orderAnswerService.updateOrderAnswer(orderAnswer),response,"200","删除成功");
    }



}
